export default {
    mounted(el, binding) {
        let width = '', height = ''
        function isResize() {
//获取当前元素的所有的计算样式
            const style = document.defaultView.getComputedStyle(el);
            if (width !== style.width || height !== style.height) {
                binding.value()
            }
            width = style.width
            height = style.height
        }
        el._vueSetInterval = setInterval(isResize, 300);
    },
    unmounted(el) {
        clearInterval(el._vueSetInterval)
    }
}
// import type { Directive, App, } from 'vue';
// import { onMounted, onUnmounted, ref } from 'vue';
// const resize:Directive = {
//     onMounted(el, binding) {
//         let width = '', height = ''
//         function isResize() {
//             //获取当前元素的所有的计算样式
//             const style = document.defaultView.getComputedStyle(el);
//             if (width !== style.width || height !== style.height) {
//                 binding.value()
//             }
//             width = style.width
//             height = style.height
//         }
//         el._vueSetInterval = setInterval(isResize, 300);
//     },
//     onUnmounted(el) {
//         clearInterval(el._vueSetInterval)
//     }
// }
// export function setupOnlyNumber(app: App) {
//
//     app.directive('resize', resize);
// }
// export default resize;


